/**
 * 中文编程系统
 */
import Domain from "./str/Domain";
import CharNode from "./CharNode";
import Switch from "./SwitchNode";

const SysType={
    TYPE:0,

    SYS_CHAR:1, //符号
    SYS_LEX:2,  //词
    SYS_YACC:3, //句
    SYS_SWITCH:4, //转换
}


export default class SwitchSystemNode {

    constructor() {
        this.lexDomain=new Domain();
        this.switchDomain=new Domain();

        this.charNode=new CharNode(this.lexDomain,SysType.SYS_CHAR);
        this.lexNode=new LexNode(this.lexDomain,SysType.SYS_LEX);
        this.yaccNode=new YaccNode(this.switchDomain,SysType.SYS_YACC);
        this.switchNode=new StactNode(this.switchDomain,SysType.SYS_SWITCH);

    }


    run(src){

        let srcIds=this.charNode.run(src);  //查找字符id
        let srcLexs=this.lexNode.run(srcIds); //分词
        let srcYacc=this.yaccNode.run(srcLexs); //生成语法树
        let srcSwitch=this.switchNode.run(srcYacc); //转换成可以识别的语法
        return srcSwitch;
    }

}
